package com.cimu.swagger.controller;

import com.cimu.swagger.dto.DemoDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * Title: DemoController
 * Copyright: Copyright (c) 2017
 *
 * date 2018年12月03日 13:16
 */
@RestController
@RequestMapping("/api/demo")
@Api(tags = "示例", description = "示例")
public class DemoController {

    @ApiOperation(value = "示例1")
    @ApiImplicitParam(name = "mobile", value = "手机号", required = true, paramType = "query")
    @ApiResponse(code = 200, message = "返回数据", response = DemoDto.class)
    @GetMapping("/example1")
    public DemoDto demo1(@ApiIgnore DemoDto demoDto) {
        return new DemoDto();
    }

    @ApiOperation(value = "示例2")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "mobile", value = "手机号", required = true, paramType = "query"),
            @ApiImplicitParam(name = "name", value = "名称", required = true, paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "返回数据", response = DemoDto.class)
    })
    @GetMapping("/example2")
    public DemoDto demo2(@ApiIgnore DemoDto demoDto) {
        return new DemoDto();
    }

    @ApiOperation(value = "示例3")
    @ApiImplicitParam(name = "code", value = "代码", required = true, paramType = "query")
    @ApiResponses({
            @ApiResponse(code = 200, message = "返回数据", response = DemoDto.class),
            @ApiResponse(code = 500, message = "异常错误"),
    })
    @GetMapping("/example3")
    public DemoDto demo3( DemoDto demoDto, String code) {
        return new DemoDto();
    }

}
